<?php
if(!isset($_SESSION))
{
	session_start();
}
include '../../connection/connection.php';
include "../../value/value_kr.php";

$idconfigcamera = $_REQUEST['idconfig_camera'];
$cameraname=$_REQUEST['cameraname'];
$servername=$_REQUEST['servername'];
$postx=$_REQUEST['postx'];
$posty=$_REQUEST['posty'];
$ipconf=$_REQUEST['ipconf'];
$port=$_REQUEST['port'];
$userid=$_REQUEST['userid'];
$pw=$_REQUEST['pw'];
$dvr=$_REQUEST['dvr'];
$mode=$_REQUEST['mode'];


	$list=$_SESSION['sort'];
	$str="cf.live_time";
	$_SESSION['sortn']=$str;
	$flagDesc=$_GET['flagDesc'];
	
	if($flagDesc==1){

		if($list[$str]=="DESC")
			$list[$str]="ASC";
		else
			$list[$str]="DESC";
	}

$sql = "UPDATE configcamera cf SET cf.`name` = '$cameraname' ,cf.`host` = '$servername', cf.go_mode='$mode' ,cf.pos_x = '$postx' , cf.pos_y ='$posty'
 , cf.DVR = '$dvr' , cf.IP = '$ipconf' , cf.`Port` = '$port' , cf.UserID='$userid' , cf.PW = '$pw'
 WHERE cf.id = '$idconfigcamera'";

$query_edit = mysql_query($sql, $connection);

$sql1 = "select cf.* from configcamera cf ";
$selectConfcamera = mysql_query($sql1." ORDER BY ".$str." ".$list[$str], $connection);
?>
<div style="overflow:scroll;overflow-x: hidden; width:100%; height:480px; background-color: #ffffff">
		     <table cellpadding="0" cellspacing="0" border="0" width="100%" class="tbchung"  id="tablebody2">
	     		<tbody>
					<?php 
                			$i = 0; 
			     		while ($row = mysql_fetch_array($selectConfcamera)){ 
			     			$i ++;?>
				     	<tr id="idrowconfcamera" onclick="onclickTableRow(this,<?=$row[id]?>);">
				     		<td style="text-align: center;width: 4%"><?=$i;?></td>
				     		<td style="text-align: center;width: 5%"><?=$row[id]?></td>
				     		<td style="width: 18%"><?php if ($row[name]==''){echo "&nbsp;";}else{?> <?=$row[name]?><?php }?></td>
				     		<td style="width: 6%"><?php if ($row[pos_x]==''){echo "&nbsp;";}else{?><?=$row[pos_x]?><?php }?></td>
				     		<td style="width: 6%"><?php if ($row[pos_y]==''){echo "&nbsp;";}else{?><?=$row[pos_y]?><?php }?></td>
				     		<td style="text-align: center;width: 6%"><?if ($row[go_mode]==1){echo $l_come;}else{echo $l_go;} ?></td>
				     		<td style="width: 20%"><?php if ($row[host]==''){echo "&nbsp;";}else{?><?=$row[host]?><?php }?></td>
				     		<td style="text-align: center;width: 4%"><?=$row[DVR]?></td>
				     		<td style="width: 10%"><?php if ($row[IP]==''){echo "&nbsp;";}else{?><?=$row[IP]?><?php }?></td>
				     		<td style="text-align: center;width: 6%"><?php if ($row[Port]==''){echo "&nbsp;";}else{?><?=$row[Port]?><?php }?></td>
				     		<td style="width: 9%"><?php if ($row[UserID]==''){echo "&nbsp;";}else{?><?=$row[UserID]?><?php }?></td>
				     		<td style="text-align: center;width: 6%" class="last"><?php if (strlen($row[PW])==0){echo "&nbsp;";}else{$vals="*"; for ($m=0;$m <strlen($row[PW]);$m++){?><?=$vals++;?><?php }}?></td>
				     	</tr>
			     	<?php 
			     			}
			     			if ($i>0 and $i<17) {
							 	foreach(range(0,17-$i) as $real){
							 		?>
							 		<tr>
								 		<td style="width:4%">&nbsp;</td>
								 		<td style="width:5%">&nbsp;</td>
								 		<td style="width:18%">&nbsp;</td>
									 	<td style="width:6%">&nbsp;</td>
									 	<td style="width:6%">&nbsp;</td>
									 	<td style="width: 6%;">&nbsp;</td>
									 	<td style="width:20%">&nbsp;</td>
								 		<td style="width:54%">&nbsp;</td>
								 		<td style="width:10%">&nbsp;</td>
									 	<td style="width:6%">&nbsp;</td>
									 	<td style="width:9%">&nbsp;</td>
									 	<td class="last" style="width: 6%;border-right: none !important;">&nbsp;</td>
								 	</tr>
							 	<?php }
							}?>
			     	
		     	</tbody>
		     </table>
		     </div>
		     	 <?php mysql_close($connection);?>